#include <iostream>
#include <string>
#include <algorithm>
#include "Server.hpp"
#include "Translate.hpp"
using namespace std;

string PingServer(const string& message)
{
    return "Pong";
}

string ConvertUpper(const string& message)
{
    string messagebuf = message;
    transform(messagebuf.begin(), messagebuf.end(), messagebuf.begin(), 
    [](unsigned char c)
    {
        return std::toupper(c);
    });
    
    return messagebuf;
}

string Translate(const string& word)
{
    translate t;
    t.Display();
    return t.GetTranslate(word);
}


int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        cout << "Incorrect use, correct use: " << endl
             << "    ./server port" << endl;
    }

    uint16_t port = stoi(argv[1]);

    Server server(port);
    server.Register("ping", PingServer);
    server.Register("convertupper", ConvertUpper);
    server.Register("translate", Translate);

    server.Init();

    server.Start();
    return 0;
}

// int main()
// {
//     translate t;
//     t.Display();
//     return 0;
// }
